import * as Api from '@/api/system/dept'

const dept = {
  state: {
  },
  mutations: {
  },
  actions: {
    GetDeptTree({ commit }, hospitalId) {
      return new Promise((resolve, reject) => {
        Api.getDeptTree(hospitalId)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    GetDeptById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.getDeptById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    SaveDept({ commit }, data) {
      return new Promise((resolve, reject) => {
        Api.saveDept(data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    UpdateDeptById({ commit }, { id, data }) {
      return new Promise((resolve, reject) => {
        Api.updateDeptById(id, data)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    },
    RemoveDeptById({ commit }, id) {
      return new Promise((resolve, reject) => {
        Api.removeDeptById(id)
          .then(res => {
            resolve(res.data)
          })
          .catch(err => {
            reject(err)
          })
      })
    }
  }
}

export default dept
